home *** CD-ROM | disk | FTP | other *** search
- /*
- Enclosed is a complete subroutine package to animate your cursors using
- acurs resources.
- I am the author.
-
- -- David Phillip Oster - Note new address. Old one has gone Bye Bye.
- -- oster@well.sf.ca.us = {backbone}!well!oster
-
- Modified to support color cursors by Brian Bechtel, blob@apple.com
- */
-
- #include "acur.h"
-
- /*
- CursorList - these resources define the black and white animated
- cursor data structure
- */
- typedef union UHand
- {
- CursHandle h;
- struct
- {
- short i;
- short fill;
- } i;
- } UHand;
-
- typedef struct CursorList
- {
- short cnt;
- short current;
- UHand curs[1];
- } CursorList, *CursorPList, **CursorHList;
-
-
- /*
- CursorList - these resources define the color animated cursor
- data structure
- */
- typedef union UCHand
- {
- CCrsrHandle h;
- struct
- {
- short i;
- short fill;
- } i;
- } UCHand;
-
- typedef struct CCursorList
- {
- short cnt;
- short current;
- UCHand curs[1];
- } CCursorList, *CCursorPList, **CCursorHList;
-
-
- /* globals
- */
- static CursorHList acurs = nil; /* used in SpinBWCursor */
- static CCursorHList cacurs = nil; /* used in SpinColorCursor */
- static SysEnvRec theWorld;
-
-
-
- static void InitColorCursors(void);
- static void InitBWCursors(void);
- static void SpinColorCursor(short delta);
- static void SpinBWCursor(short delta);
-
-
- void InitCursors()
- {
- SysEnvirons(curSysEnvVers, &theWorld);
- if (theWorld.hasColorQD)
- InitColorCursors();
- else
- InitBWCursors();
- }
- /* InitColorCursors - initialize our color anuimated cursor structure
- */
- void InitColorCursors()
- {
- CCrsrHandle h;
- short i;
-
- if (nil != (cacurs = (CCursorHList) GetResource('acur', 0) ) )
- {
- for(i = 0; i < (**cacurs).cnt; i++)
- {
- h = (CCrsrHandle) GetCCursor((**cacurs).curs[i].i.i);
- MoveHHi((Handle) h);
- HLock((Handle) h);
- (**cacurs).curs[i].h = h;
- }
- }
- }
-
- /* InitBWCursors - initialize our black and white anuimated cursor structure
- */
- void InitBWCursors()
- {
- CursHandle h;
- short i;
-
- if (nil != (acurs = (CursorHList) GetResource('acur', 0) ) )
- {
- for(i = 0; i < (**acurs).cnt; i++)
- {
- h = (CursHandle) GetCursor((**acurs).curs[i].i.i);
- MoveHHi((Handle) h);
- HLock((Handle) h);
- (**acurs).curs[i].h = h;
- }
- }
- }
-
- /* SpinCursor - transit the cursor to the next in the series.
- delta should be 1 to go forward,
- -1 to go backward
- */
- void SpinCursor(short delta)
- {
- if (theWorld.hasColorQD)
- SpinColorCursor(delta);
- else
- SpinBWCursor(delta);
- }
-
- /* SpinColorCursor - transit the cursor to the next in the series.
- delta should be 1 to go forward,
- -1 to go backward
- */
- void SpinColorCursor(short delta)
- {
- short c;
-
- if(cacurs != nil){
- c = (**cacurs).current + delta;
- if(c >= (**cacurs).cnt){
- c = 0;
- }else if(c < 0){
- c = (**cacurs).cnt-1;
- }
- (**cacurs).current = c;
- SetCCursor( ((**cacurs).curs[c].h) );
- }
- }
-
- /* SpinBWCursor - transit the cursor to the next in the series.
- delta should be 1 to go forward,
- -1 to go backward
- */
- void SpinBWCursor(short delta)
- {
- short c;
-
- if(acurs != nil){
- c = (**acurs).current + delta;
- if(c >= (**acurs).cnt){
- c = 0;
- }else if(c < 0){
- c = (**acurs).cnt-1;
- }
- (**acurs).current = c;
- SetCursor( *((**acurs).curs[c].h) );
- }
- }
-
-